package com.hyhy.hycloud.commons.web;

import com.hyhy.hycloud.commons.constant.Marker;
import com.hyhy.hycloud.commons.dto.InvokeResult;
import com.hyhy.hycloud.commons.exception.HyCloudRuntimeException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author lanpengfei
 * @date 2018/7/27
 */
@RestControllerAdvice
@Slf4j
public class HyCloudExceptionHandler {

    @ExceptionHandler(HyCloudRuntimeException.class)
    public InvokeResult<StackTraceElement> handleHyCloudRuntimeException(HyCloudRuntimeException exception) {
        log.error(Marker.ERROR + exception.getMessage() + ":{}", exception);
        return InvokeResult.error(exception);
    }
}
